package com.qpkj.web.controller.oms;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.qpkj.common.annotation.Log;
import com.qpkj.common.core.controller.BaseController;
import com.qpkj.common.core.domain.AjaxResult;
import com.qpkj.common.enums.BusinessType;
import com.qpkj.oms.domain.OmsProductionRecoder;
import com.qpkj.oms.service.IOmsProductionRecoderService;
import com.qpkj.common.utils.poi.ExcelUtil;
import com.qpkj.common.core.page.TableDataInfo;

/**
 * 生产记录Controller
 *
 * @author ruoyi
 * @date 2022-12-25
 */
@RestController
@RequestMapping("/oms/productionrecoder")
public class OmsProductionRecoderController extends BaseController {
    @Autowired
    private IOmsProductionRecoderService omsProductionRecoderService;

    /**
     * 查询生产记录列表
     */
   // @PreAuthorize("@ss.hasPermi('oms:productionrecoder:list')")
    @GetMapping("/list")
    public TableDataInfo list(OmsProductionRecoder omsProductionRecoder) {
        startPage();
        List<OmsProductionRecoder> list = omsProductionRecoderService.selectOmsProductionRecoderList(omsProductionRecoder);
        return getDataTable(list);
    }

    /**
     * 导出生产记录列表
     */
    //@PreAuthorize("@ss.hasPermi('oms:productionrecoder:export')")
    @Log(title = "生产记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OmsProductionRecoder omsProductionRecoder) {
        List<OmsProductionRecoder> list = omsProductionRecoderService.selectOmsProductionRecoderList(omsProductionRecoder);
        ExcelUtil<OmsProductionRecoder> util = new ExcelUtil<OmsProductionRecoder>(OmsProductionRecoder.class);
        util.exportExcel(response, list, "生产记录数据");
    }

    /**
     * 获取生产记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('oms:productionrecoder:query')")
    @GetMapping(value = "/{productionId}")
    public AjaxResult getInfo(@PathVariable("productionId") Long productionId) {
        return success(omsProductionRecoderService.selectOmsProductionRecoderByProductionId(productionId));
    }

    /**
     * 新增生产记录
     */
    @PreAuthorize("@ss.hasPermi('oms:productionrecoder:add')")
    @Log(title = "生产记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OmsProductionRecoder omsProductionRecoder) {
        return toAjax(omsProductionRecoderService.insertOmsProductionRecoder(omsProductionRecoder));
    }

    /**
     * 修改生产记录
     */
    @PreAuthorize("@ss.hasPermi('oms:productionrecoder:edit')")
    @Log(title = "生产记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OmsProductionRecoder omsProductionRecoder) {
        return toAjax(omsProductionRecoderService.updateOmsProductionRecoder(omsProductionRecoder));
    }

    /**
     * 删除生产记录
     */
    @PreAuthorize("@ss.hasPermi('oms:productionrecoder:remove')")
    @Log(title = "生产记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{productionIds}")
    public AjaxResult remove(@PathVariable Long[] productionIds) {
        return toAjax(omsProductionRecoderService.deleteOmsProductionRecoderByProductionIds(productionIds));
    }
}
